package cn.iocoder.yudao.module.api.member.user.enums;

import cn.hutool.core.util.ArrayUtil;
import cn.iocoder.yudao.framework.business.basic.enums.EnumValuable;
import cn.iocoder.yudao.module.api.infrastructure.sms.enums.SmsSceneEnum;
import com.baomidou.mybatisplus.annotation.EnumValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 用户短信验证码发送场景的枚举
 *
 * @author 山野羡民
 * @see SmsSceneEnum
 */
@Getter
@AllArgsConstructor
public enum MemberSmsSceneEnum implements EnumValuable {

    MEMBER_REGISTER(0, "user-sms-register", "前台用户 - 手机号注册"),
    ;

    private final Integer value;
    @EnumValue
    private final String code;
    private final String name;

    public static String getTemplateCodeByScene(Integer value) {
        MemberSmsSceneEnum smsSceneEnum = ArrayUtil.firstMatch(it -> it.getValue().equals(value),
                values());
        if (smsSceneEnum == null) {
            return "";
        }
        return smsSceneEnum.getCode();
    }

}
